package grape.base.service.message.api;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import grape.base.service.job.po.Job;
import grape.base.service.message.po.MessageTemplate;
import grape.common.exception.runtime.InvalidParamsException;
import grape.common.service.common.IBaseService;

/**
 * <p>
 * 消息内容模板表 服务类
 * </p>
 *
 * @author yangwei
 * @since 2020-03-18
 */
public interface IMessageTemplateService extends IBaseService<MessageTemplate> {
    /**
     * 判断编码是否已存在
     * @param code
     * @return
     */
    default boolean existCode(String code){
        if (isStrEmpty(code)) {
            throw new InvalidParamsException("code 不能为空");
        }
        MessageTemplate messageTemplate = new MessageTemplate();
        messageTemplate.setCode(code);
        int r = count(Wrappers.query(messageTemplate));
        return r > 0;
    }
}
